Skip to content

feat(json-renderer): share the field descriptor and widget rule pipeline - #35

Merged
pyramation merged 1 commit into
mainfrom
feat/form-resolver-core
Aug 22, 2026
Merged

feat(json-renderer): share the field descriptor and widget rule pipeline#35
pyramation merged 1 commit into
mainfrom
feat/form-resolver-core

Conversation

@pyramation

@pyramation pyramation commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Two things, both prerequisites for the rest of phase 2 of constructive-io/constructive-planning#1822.

1. @fbp/evaluator floor. flow-to-blocks allowed ^1.3.0, and 1.3.0 is permanently uninstallable (it shipped "@fbp/types": "workspace:*"). Floor raised to ^1.5.0, which also lets the temporary workarounds go: the "@fbp/evaluator>@fbp/types" override in pnpm-workspace.yaml and the matching override in the packed-consumer check.

2. form-resolver-core. The field → node rule pipeline lived inside json-schema-to-blocks, so meta-to-blocks (and later HITL task forms / function inputs) would each fork their own copy of decisions like "format: uri renders as a file picker". It now lives in json-renderer/rules as a source-neutral layer — still no React, no @constructive-io/*, and no Constructive widget names in the generic package:

interface FieldDescriptor<TType> {
  name; path; required;
  dataType?; format?; label?; description?;
  enumValues?; nullable?; readOnly?; defaultValue?;
  constraints?: NodeConstraints;
  hints: FieldHints<TType>;   // the x-ui shape, generalized
}

composeWidgetRules(defaults, rules?, replaceDefaults?)  // caller rules first
applyWidgetRules(descriptor, rules, fallbackType)       // first match wins
fieldNodeProps(descriptor)                              // shared field props
compareFieldOrder(a, b)                                 // hints.order, else source order

json-schema-to-blocks keeps every one of its exported names and now specializes rather than duplicates:

-export interface FieldContext { schema; name; path; required; type?; ui; resolve }
+export interface FieldContext extends FieldDescriptor<UINodeType> { schema; type?; ui; resolve }
-export interface WidgetRule { ... }
+export type WidgetRule = CoreWidgetRule<FieldContext, UINodeType, UINode>;

So a rule matches on ctx.dataType/ctx.format/ctx.enumValues/ctx.constraints when the decision is source-neutral (those rules will work verbatim against a _meta column), and still reaches into ctx.schema for genuinely schema-specific keywords like multipleOf. ctx.ui stays as an alias of ctx.hints, so existing app rules keep compiling.

No behavior change intended: the 23 existing conversion tests pass untouched (x-ui, required/disabled/readOnly, defaults and const, constraints, enums, recursion, variants, ordering, $ref cycles), plus 14 new tests for the generic helpers.

Verification

pnpm build, pnpm lint:types, pnpm test, pnpm check, pnpm pack:check all green under Node 24 / pnpm 10.28.0 (installed directly, not through corepack — a corepack shim resolves pnpm per-directory, so pack:check's throwaway consumers outside the workspace got pnpm 11 and failed on ERR_PNPM_IGNORED_BUILDS: esbuild). CI installs pnpm via pnpm/action-setup, so it is unaffected.

Link to Devin session: https://app.devin.ai/sessions/027937d092794c92a31c6ee49c513f59
Requested by: @pyramation

…pipeline

Raise flow-to-blocks off the broken @fbp/evaluator@1.3.0 floor and move the
field -> node rule pipeline into json-renderer so every document source shares
it.
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@tenki-reviewer

tenki-reviewer Bot commented Aug 22, 2026

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR consolidates schema-to-UI lowering logic: packages/json-renderer/src/rules.ts introduces generic fieldNodeProps/containerProps helpers and a FieldContext that now extends the shared FieldDescriptor type, and packages/json-schema-to-blocks (convert.ts, rules.ts, types.ts) is refactored to reuse them. json-schema-to-blocks gains a json-renderer: workspace:^ dependency, and flow-to-blocks bumps @fbp/evaluator from ^1.3.0 to ^1.5.0; pnpm-workspace.yaml drops now-unneeded overrides and scripts/check-packed-packages.ts updates the packed-tarball assertions.

Files Change
json-renderer/src/rules.ts, index.ts, rules.test.ts New generic field/container descriptor helpers shared by both packages, with tests.
json-schema-to-blocks/src/convert.ts, rules.ts, types.ts Refactored to lower through the shared generic descriptor model.
flow-to-blocks/package.json, json-schema-to-blocks/package.json, pnpm-workspace.yaml Dependency range bump and workspace override cleanup.
scripts/check-packed-packages.ts Updated packed-manifest assertions for the new dependency set.

Reviewed commit: 5170812

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​fbp/​evaluator@​1.5.0771007490100

View full report

@pyramation
pyramation merged commit ae5d1c7 into main Aug 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant